﻿using System;
using System.Collections.ObjectModel;
using System.Windows.Input;
using Samurai.Infrastructure;

namespace Samurai.Client
{
    public class DeleteFromRepositoryCommand : ICommand
    {
        private readonly ObservableCollection<Repository> _repositories;

        public DeleteFromRepositoryCommand(ObservableCollection<Repository> repositories)
        {
            _repositories = repositories;
        }

        public void Execute(object parameter)
        {
            if (parameter != null)
            {
                var repositoryqqq = (Repository)parameter;
                DAL.Manager.Instance.RemoveFromRepository(repositoryqqq);
                _repositories.Remove(repositoryqqq);
            }
        }

        public bool CanExecute(object parameter)
        {
            return true;
        }

        public event EventHandler CanExecuteChanged;
    }
}
